import pygame
import random
import time

pygame.init() # pygame display init
resolution = (768, 432) # Defines the games resolution
screen=pygame.display.set_mode(resolution) # Window size
keys=pygame.key.get_pressed()

pygame.display.set_caption("")
font = pygame.font.SysFont("monospace", 28)

score = 0
phys = 25
clock = 0
tgl = 1



# Sprites
player = pygame.image.load("player.png")
back = pygame.image.load("back.png")
tomato = pygame.image.load("tomato.png")
# player_slide = pygame.image.load("player_slide.png")
# coin = pygame.imgae.load("coin.png")

# Positions
playerposx = 32
playerposy = 300
tomatoposx = 768
tomatoposy = 350




while 1:
	screen.fill(0)
	scoreb = font.render("Score: "+str(score),  1, (0,0,0))
	screen.blit(scoreb, (0,0))
	screen.blit(back, (0,0))
	screen.blit(player, (playerposx, playerposy))
	screen.blit(tomato, (tomatoposx,tomatoposy))
	screen.blit(scoreb, (0,0))

	
	if tgl == 1:
		tomatoposx -= 1 # Default 3
	
	if tomatoposx < 60:
		if tomatoposx > 32:
			if playerposy == 300:
				tgl = 0
	

	
	
	if tomatoposx < -27: # Tomatocrap
		tomatoposx = 767
		score += 1
		
	if phys < 25:
		phys +=1
		
	if clock == 1:
		if phys < 200:
			phys +=1
			
	if phys == 200:
		playerposy=300
		phys=0
		clock=0
		
	

	for event in pygame.event.get():
			if event.type == pygame.KEYDOWN:
				if event.key == pygame.K_SPACE:
					if phys == 25:
						if tgl == 1:
							playerposy=200
							clock=1
					
					
					
					
	# Devboard Section
	print("###DEVBOARD###")
	print("Phys:",phys)
	print("Clock:",clock)
		
	pygame.display.flip()
	for event in pygame.event.get():
		if event.type==pygame.QUIT: # quiting
			pygame.quit()
			exit(0)
